package com.bw.repair.adapter

import android.graphics.Color
import android.widget.TextView
import com.bw.repair.R
import com.bw.repair.entity.RepairEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class RepairAdapter:BaseQuickAdapter<RepairEntity,BaseViewHolder>(R.layout.item_repair) {
    override fun convert(holder: BaseViewHolder, item: RepairEntity) {
        holder.setText(R.id.gong_num,"工单号：${item.orderNumber}")
        holder.setText(R.id.baoziu_time,"报修时间：${item.repairTime}")
        holder.setText(R.id.baoziu_person,"报修人：${item.repairName}")
        holder.setText(R.id.phone,"联系电话：${item.contactMethod}")
        holder.setText(R.id.address,"位置：${item.repairLocation}")
        holder.setText(R.id.guzhang_desc,"${item.faultDescription}")

        val state = holder.getView<TextView>(R.id.state)
        val stateStr = item.processingStatus
        if(stateStr=="处理中"){
            state.text = "处理中"
            state.setBackgroundResource(R.drawable.bg_blue)
            state.setTextColor(Color.parseColor("#1E88E5"))
        }else if(stateStr=="已完成"){
            state.text = "已完成"
            state.setBackgroundResource(R.drawable.bg_green)
            state.setTextColor(Color.parseColor("#43A047"))
        }else if(stateStr=="待处理"){
            state.text = "待处理"
            state.setBackgroundResource(R.drawable.bg_orange)
            state.setTextColor(Color.parseColor("#F57C00"))
        }


    }
}